import { PostLogin, getInfo } from "@/api/login";
export default {
  namespaced: true,
  state: {
    token: "",
    userInfo: "",
  },
  mutations: {
    changetoken(state, value) {
      state.token = value;
    },
    LOGOUT(state) {
      state.code = "";
      state.token = "";
    },
    SETUSERINFO(state, value) {
      state.userInfo = value;
    },
  },
  actions: {
    async toLogin(context, value) {
      const res = await PostLogin(value);
      console.log(res);
      context.commit("changetoken", res.data.token);
    },
    async getUserInfo(ctx) {
      const res = await getInfo();
      console.log("用户信息", res);
      ctx.commit("SETUSERINFO", res.data);
      console.log(ctx);
    },
  },
};
